package com.lry.basic.juc;

public class DisOrder {

    static int a,b,x,y,i;
//2767114
    public static void main(String[] args) throws InterruptedException {

        for(;;){
            ++i;
            a=0;b=0;x=0;y=0;
            Thread t1 = new Thread(new Runnable() {
                @Override
                public void run() {
                    a = 1;
                    x = b;
                }
            });

            Thread t2 = new Thread(new Runnable() {
                @Override
                public void run() {
                    b = 2;
                    y = a;
                }
            });

            t1.start();
            t2.start();
            t1.join();
            t2.join();

            if(x==0&&y==0){
                System.out.println(i);
                break;
            }
        }
    }
}
